package com.health.controller.mobile;

import com.health.common.R;
import com.health.dto.OrderDto;
import com.health.service.OrderService;
import com.health.vo.OrderInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/mobile/order")
@Api(tags = "移动端预约模块")
@Slf4j
@RequiredArgsConstructor
public class MobileOrderController {

    private final OrderService orderService;


    @PostMapping("/submitOrder")
    @ApiOperation(value = "提交预约")
    public R submitOrder(@RequestBody OrderDto dto) {
        log.info("提交预约 {}", dto);
        Integer id = orderService.submitOrder(dto);
        return R.success(id);
    }

    @GetMapping("/{id}")
    @ApiOperation(value = "获取预约信息")
    public R getOrderInfo(@PathVariable Integer id) {
        log.info("获取预约信息 {}", id);
        OrderInfoVO orderInfoVO = orderService.getOrderInfo(id);
        return R.success(orderInfoVO);
    }

    /**
     * 获取支付二维码
     */
    @ApiOperation(value = "获取支付二维码")
    @PostMapping("/pay/{id}")
    public R orderPay(@PathVariable Long id) {
        log.info("获取支付二维码 {}", id);
        String url = orderService.orderPay(id);
        return R.success(url);
    }
}
